/*
 * Copyright (c) 2002-2004, xRhino, Inc.
 *
 * This library is free software; you can redistribute and/or modify
 * it under the terms of the dual license distributed with this source
 * package (a combined Trolltech QPL/GPL-compatible license)
 *
 * Under this dual license scheme, a separate license is available for use of 
 * this code with a proprietary (closed) system. For more information on the 
 * license, please see the LICENSE file distributed with this source package.
 */
#ifndef SUGLENGTH_H
#define SUGLENGTH_H

#include "SugTypes.h"

/**
 * The class responsible for length and unit conversion.  It is a direct 
 * translation from the SVG IDL.
 */
class SugLength
{
  protected:
   /**
    * This unit type corresponding to the enumeration below.
    */
    unsigned short mUnitType;

   /**
    * The value given by the user
    */
   SugRealType mValue;

   /**
    * The value after it has been translated to a certain unit type.
    */
   SugRealType mValueInSpecifiedUnits;

   /**
    * The value as a string (unused)
    */
   char* mValueAsString;

  public:
   /**
    * An enumeration of unit types.
    */
    enum {SVG_LENGTHTYPE_UNKNOWN = 0, SVG_LENGTHTYPE_NUMBER = 1, SVG_LENGTHTYPE_PERCENTAGE = 2,
          SVG_LENGTHTYPE_EMS = 3, SVG_LENGTHTYPE_EXS = 4, SVG_LENGTHTYPE_PX = 5,
          SVG_LENGTHTYPE_CM = 6, SVG_LENGTHTYPE_MM = 7, SVG_LENGTHTYPE_IN = 8,
          SVG_LENGTHTYPE_PT = 9, SVG_LENGTHTYPE_PC = 10};

   /**
    * Returns the unit type
    */
    unsigned short getUnitType();

   /**
    * Returns the value
    */
   SugRealType getValue();

   /**
    * Returns the value in the specified units
    */
   SugRealType getValueInSpecifiedUnits();

   /**
    * Returns the value as a string (unused)
    */
   char* getValueAsString();

   /**
    * Creates a new value with a given unit type
    */
   void newValueSpecifiedUnits(unsigned short unitType, SugRealType valueInSpecifiedUnits);

   /**
    * Converts value to the new unit type.
    */
   void convertToSpecifiedUnits(unsigned short unitType);

   /**
    * The class constructor
    */
   SugLength();

   /**
    * The class destructor
    */
   ~SugLength();

};

#endif
